﻿@model ApplicationSettings
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="renderer" content="webkit" />
    <title>@Model.DefaultTitle</title>
    <meta name="apple-mobile-web-app-title" content="@Model.DefaultTitle" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="keywords" content="@Model.DefaultMetaKeywords" />
    <meta name="description" content="@Model.DefaultMetaDescription" />
    <meta name="author" content="minguiluo@163.com" />
    <meta name="copyright" content="本网站版权归AgileHR所有">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no">
    <meta name="format-detection" content="address=no">
    <meta name="msapplication-TileColor" content="#000" /> <!-- Windows 8 磁贴颜色 -->
    <meta name="msapplication-TileImage" content="~/favicon.ico" /> <!-- Windows 8 磁贴图标 -->
    <meta name="applicable-device" content="pc,mobile" />
    <!-- 搜索引擎抓取 -->
    <meta name="robots" content="index,follow" />
    <link rel="icon" href="~/favicon.ico" />
    <link href="~/Content/css/framework-font.css" rel="stylesheet" />
    <link href="~/Content/css/framework-login.css" rel="stylesheet" />
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script src="~/Content/js/cookie/jquery.cookie.js"></script>
    <script src="~/Content/js/md5/jquery.md5.js"></script>
    <!--[if lte IE 8]>
        <div id="errorie"><div>您还在使用老掉牙的IE，正常使用系统前请升级您的浏览器到 IE8以上版本 <a target="_blank" href="http://windows.microsoft.com/zh-cn/internet-explorer/ie-8-worldwide-languages">点击升级</a>&nbsp;&nbsp;强烈建议您更改换浏览器：<a href="http://down.tech.sina.com.cn/content/40975.html" target="_blank">谷歌 Chrome</a></div></div>
    <![endif]-->
    <style type="text/css">
        .oauth {
            padding-top: 10px;
        }

            .oauth img {
                height: 40px;
                width: 40px;
            }
    </style>
</head>
<body>
    <div class="wrapper">
        <div class="container">
            <div class="logo">
                <i class="fa fa-modx"></i>
                <h1>@Model.DefaultTitle</h1>
            </div>
            <form class="form" style="margin: 10px;">
                <div class="row">
                    <input id="txt_account" type="text" placeholder="用户名/手机号/邮箱" autocomplete="off">
                    <i class="fa fa-user"></i>
                </div>
                <div class="row">
                    <input id="txt_password" type="password" placeholder="登录密码" autocomplete="off">
                    <i class="fa fa-key"></i>
                </div>
                <div class="row">
                    <input id="txt_code" maxlength="4" type="text" placeholder="验证码" style="width: 190px; float: left;">
                    <div style=" float: right; padding-top: 14px; ">
                        看不清？<a id="switchCode" href="javascript:void();" style="text-decoration: none;">换一张</a>
                        <img id="imgcode" class="authcode" src="/Login/GetAuthCode" width="80" height="25" />
                    </div>
                </div>
                <div class="row">
                    <button id="login_button" type="button"><span>登录</span></button>
                </div>
                <div class="row oauth">
                    @{
                        foreach(var item in SupportedOAuth.List.OrderByDescending(p => p.available)) {
                            if(item.available) {
                                <a href="/oauth/@(item.platform)" title="使用@(item.platformName)账号登录" class="plat-icon ml-2 mr-2 mt-4">
                                    <img src="/Content/img/oauth/@(item.platform.ToLower()).png" />
                                </a>
                            } else {
                                <a href="/oauth/@(item.platform)" onclick="return confirm('暂未获得平台【@(item.platformName)】应用Id，不保证正确相应您的请求。\n欢迎提供测试信息，感谢！联系QQ：271391233')" title="使用@(item.platformName)账号登录" class="plat-icon testing ml-2 mr-2 mt-4">
                                    <img src="/Content/img/oauth/@(item.platform.ToLower()).png" />
                                </a>
                            }
                        }
                    }
                </div>
            </form>
            <div class="login_tips"></div>
        </div>
        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <div class="copyright">
        <a style="text-decoration:none;color:#fff;">@Model.DefaultTitle</a>
        <br>
        适用浏览器：IE8以上、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗.
    </div>
    <script type="text/javascript">
        (function ($) {
            $.login = {
                formMessage: function (msg) {
                    $('.login_tips').find('.tips_msg').remove();
                    $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                },
                loginClick: function () {
                    var $username = $("#txt_account");
                    var $password = $("#txt_password");
                    var $code = $("#txt_code");
                    if ($username.val() == "") {
                        $username.focus();
                        $.login.formMessage('请输入用户名/手机号/邮箱。');
                        return false;
                    } else if ($password.val() == "") {
                        $password.focus();
                        $.login.formMessage('请输入登录密码。');
                        return false;
                    } else if ($code.val() == "") {
                        $code.focus();
                        $.login.formMessage('请输入验证码。');
                        return false;
                    } else {
                        $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                        $.ajax({
                            url: "/Login/CheckLogin",
                            data: { username: $.trim($username.val()), password: $.md5($.trim($password.val())), code: $.trim($code.val()) },
                            type: "post",
                            dataType: "json",
                            success: function (data) {
                                if (data.StatusCode == "200") {
                                    $("#login_button").find('span').html("登录成功，正在跳转...");
                                    window.setTimeout(function () {
                                        window.location.href = "/Home/Index";
                                    }, 500);
                                } else {
                                    $("#login_button").removeAttr('disabled').find('span').html("登录");
                                    $("#switchCode").trigger("click");
                                    $code.val('');
                                    $.login.formMessage(data.Message);
                                }
                            }
                        });
                    }
                },
                init: function () {
                    $('.wrapper').height($(window).height());
                    $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    $(window).resize(function (e) {
                        $('.wrapper').height($(window).height());
                        $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
                    });
                    $("#switchCode").click(function () {
                        $("#imgcode").attr("src", "/Login/GetAuthCode?time=" + Math.random());
                    });
                    $("#imgcode").click(function () {
                        $("#imgcode").attr("src", "/Login/GetAuthCode?time=" + Math.random());
                    });
                    var login_error = top.$.cookie('nfine_login_error');
                    if (login_error != null) {
                        switch (login_error) {
                            case "overdue":
                                $.login.formMessage("系统登录已超时,请重新登录");
                                break;
                            case "OnLine":
                                $.login.formMessage("您的帐号已在其它地方登录,请重新登录");
                                break;
                            case "-1":
                                $.login.formMessage("系统未知错误,请重新登录");
                                break;
                        }
                        top.$.cookie('nfine_login_error', '', { path: "/", expires: -1 });
                    }
                    $("#login_button").click(function () {
                        $.login.loginClick();
                    });
                    document.onkeydown = function (e) {
                        if (!e) e = window.event;
                        if ((e.keyCode || e.which) == 13) {
                            document.getElementById("login_button").focus();
                            document.getElementById("login_button").click();
                        }
                    }
                }
            };
            $(function () {
                $.login.init();
            });
        })(jQuery);
    </script>
</body>
</html>
